import {createRouter, createWebHashHistory, createWebHistory} from 'vue-router'
// import HomeView from '@/views/HomeView.vue'
// import SearchView from '@/views/SearchView.vue'
// import NotFind from '@/views/NotFind.vue'

const routes = [
  // {path: '/home', component: HomeView},
  // {path: '/search', component: SearchView}
  // 重定向
  // path 解析到的地址，跳转到redirect对应的地址
  // 路由对应的页面默认会打包到一起，增加应用的大小
  // {path: '/home', component: HomeView},
  // /:words必须要传递
  // /:words?参数可选，不写也可以
  // {path: '/search/:words?', name:'search', component: SearchView},
  // {path: '/:catchAll(.*)', name:'NotFound', component: NotFind }, //最后一个

  // 懒加载、
  // 懒加载的路由页面，默认不会下载到用户的浏览器中
// 访问对应路由的时候才会去加载
  {path: '/', redirect: '/home'},
    {path: '/home',name:'home', component: ()=>import('@/views/HomeView.vue')},
    {path: '/my',name:'my', component: ()=>import('@/views/MyView.vue')},
    {name: 'search', path: '/search/:words?', component: ()=>import('@/views/SearchView.vue')},
    {path: '/:catchAll(.*)',naem:'NotFound', component: ()=>import('@/views/NotFind.vue') }
]

const router = createRouter({
  // hash 模式 url 中有#
  // history: createWebHashHistory(),
  // routes

  //history 模式，没有# ,url 更为精美(较为常用的模式)
  history: createWebHistory(),
  routes
})

export default router